package com.neulogistics.contrib.warehouse.infrastructure.persistence.converter;

import cn.hutool.json.JSONUtil;
import com.neulogistics.contrib.warehouse.domain.model.aggregate.Inventory;
import com.neulogistics.contrib.warehouse.domain.model.valueobject.Address;
import com.neulogistics.contrib.warehouse.infrastructure.persistence.orm.po.InventoryPO;
import org.springframework.beans.BeanUtils;

public class InventoryEntityPOConverter {
    public static InventoryPO entityToPO(Inventory inventory){
        if(inventory == null)
            return null;

        InventoryPO inventoryPO = new InventoryPO();
        // 复制普通属性
        BeanUtils.copyProperties(inventory, inventoryPO);

        return inventoryPO;
    }

    public static Inventory POToEntity(InventoryPO inventoryPO){
        if(inventoryPO == null)
            return null;

        Inventory inventory = new Inventory();
        // 复制普通属性, id是可以在这里被复制进去的
        BeanUtils.copyProperties(inventoryPO, inventory);

        return inventory;
    }
}
